function inputAssetType(){		
	var status;
	if (Ext.getCmp('activeType').getValue() == true)
		status = 'true';
	else 
		status = 'false';

	var typeId = Ext.getCmp('typeIdType').getValue();
	var abId = Ext.getCmp('abIdType').getValue();
	var type = Ext.getCmp('type').getValue();
		
	if(Ext.getCmp('type').getValue() == null || Ext.getCmp('type').getValue() == "") {
		Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'Field Type Required',
	        icon: Ext.Msg.WARNING
	    });
	} else {
		var data = {TYPE_ID:typeId, AB_ID: abId, TYPE:type, ACTIVE:status, USER:""};
		
		if (Ext.getCmp('ButtonInsertType').getText()=="Add Type"){
			 var url  = './Services/DataMaster/AssetType/Add';
			 PostData(data,url,"Insert");
		}else{
			 var url  = './Services/DataMaster/AssetType/Update';
			 PostData(data,url,"Update");
		}                                                   

		Ext.getCmp('ButtonInsertType').setText("Add Type");
		emptyAssetType();
		Ext.getStore('AssetDataMaster.AssetType').load();
		Ext.getStore('AssetDataMaster.Type').load();
	}

}

function deleteAssetType(){
	var rec = Ext.getCmp('tableAssetType').getSelectionModel().getSelection();
	if (rec.length>0){
		  Ext.MessageBox.confirm('Delete', 'Are you sure ?', function(btn) {
		        if (btn === 'yes') {
		        	 for (var i = 0; i<rec.length ; i++){
		     	    	var id = rec[i].get('TYPE_ID');
		     	    	var data = {TYPE_ID: id};
		     	    	var url  = './Services/DataMaster/AssetType/Delete';
		     	    	PostData(data,url,"Delete");
		     	    }
		        	refreshAssetType();		        
		        }
		    });
	}else{
    	Ext.MessageBox.show({
		 	title: 'WARNING!',
	        msg: 'No Data Selected',
	        icon: Ext.Msg.WARNING
	    });	
    }
}

function getValueAssetType(){
	Ext.getCmp("categoryType").setDisabled(true);
	Ext.getCmp("subCategoryType").setDisabled(true);
	Ext.getCmp("brandType").setDisabled(true);
	Ext.getCmp("abIdType").setDisabled(true);
	Ext.getCmp("typeIdType").setDisabled(true);
	Ext.getCmp("ButtonClearType").setDisabled(true);
    Ext.getCmp('abIdType').setValue(Ext.getCmp('abIdBrand').getValue());
    Ext.getCmp('categoryType').setValue(Ext.getCmp('categoryBrand').getValue());
    Ext.getCmp('subCategoryType').setValue(Ext.getCmp('subCategoryBrand').getValue());
    Ext.getCmp('brandType').setValue(Ext.getCmp('brand').getValue());
    emptyAssetType();
    searchAssetType();
}

function getValueGridType(record){
	Ext.getCmp("ButtonClearType").setDisabled(false);
	Ext.getCmp('ButtonInsertType').setText('Update Type');
    Ext.getCmp('typeIdType').setValue(record.get('TYPE_ID'));
    Ext.getCmp('type').setValue(record.get('TYPE'));
    if (record.get('ACTIVE')=="true"){
    	Ext.getCmp('activeType').setValue(true);
    }else{
    	Ext.getCmp('inactiveType').setValue(true);
    }  
}

function emptyAssetType(){
	Ext.getCmp('ButtonInsertType').setText('Add Type');
	Ext.getCmp('typeIdType').setValue("");
	Ext.getCmp('type').setValue("");
	Ext.getCmp('activeType').setValue(true);	
}

function searchAssetType(){
	var brand = Ext.getCmp("brandType").getValue();
	var keyword = Ext.getCmp("keywordType").getValue();
	Ext.getStore('Administration.AssetType').getProxy().url = "./Services/DataMaster/AssetType/List?BRAND="+brand+"&keyword="+keyword+"";
	Ext.getStore('Administration.AssetType').load();	
}

function refreshAssetType(){
	Ext.getCmp('keywordType').setValue("");
	searchAssetType();
}
